草庐IT

asp.net - 导入 SiteFinity

全部标签

go - 如何在 Go 源代码目录中列出导入的模块

是否有工具或最简单的方法来列出go源代码目录中的所有导入包?例如:$golist_importsa_directory/github.com/bla/blagithub.com/foo/barLOCAL/module/path 最佳答案 啊找到了way..golist-f'{{join.Deps"\n"}}'|xargsgolist-f'{{ifnot.Standard}}{{.ImportPath}}{{end}}'|sort|uniq 关于go-如何在Go源代码目录中列出导入的模块,

go - 如何更改导入文件?

我在golang中有以下功能:import("github.com/aws/aws-sdk-go/service/iam""github.com/aws/aws-sdk-go/aws/session""fmt")funcNewIAM()*SphinxIAM{//awsConfig:=aws.NewConfig()sess,err:=session.NewSession()iferr!=nil{fmt.Println("Failedtocreatesession,",err)returnnil}session:=&SphinxIAM{iam:iam.New(sess)}returnses

Go导入返回 "unused import"

我是goLang的新手。我正在尝试从intellij构建一个项目,该项目使用git库中的一个包:import("github.com/aerospike/aerospike-client-go")但我得到:“未使用的导入”我已经将我的gopath设置为\users\myuser\go并将其添加到intelij设置中,但我现在unusedimport并且项目无法识别第3方对象。我应该将模块导入我的解决方案吗?我看到它存在于文件系统中:\users\myuser\src\github.com\aerospike\aerospike-client-go你能帮帮我吗?谢谢

postgresql - 非标准导入 github.com/lib/pq"in statdard package

这个问题在这里已经有了答案:golangwhatisimportsideeffect(1个回答)Whatdoesanunderscoreinfrontofanimportstatementmean?(5个答案)Importsideeffects(1个回答)关闭4年前。我一直遇到这个问题,我不明白为什么封装模型import("database/sql""fmt"_"github.com/lib/pq")const(host="localhost"port=5432user="postgres"password="postgres"dbname="postgres")vardb*sql.D

go - 单元测试不覆盖本地导入包

我是golang的新手,想了解如何让这个场景发挥作用?这是我的结构GOPATH设置为/Users/xyz/project/Users/xyz/project/src/main.go//importcalculatorandcallSUMwithtwointegeres/Users/xyz/project/src/main_test.go//testfunction/Users/xyz/project/src/calculator/sum.go//SUMfunction(addtwointegers)我有一个主要的go文件,它导入“计算器”,这是一个本地包。当我运行时gotest-cov

go - 无法将 String 转换为 *net.TCPlistener 类型

我想将字符串放入net.Listener中,但出现错误:./server.go:26:23:cannotusemainServer(typeinterface{})astypestringinargumenttonet.Listen:needtypeassertion./server.go:27:28:cannotusegpServer(typeinterface{})astypestringinargumenttonet.Listen:needtypeassertion这是我的代码:viper.SetConfigFile("config.json")viper.AddConfigPa

go - 在 IntelliJ 中,即使启用了 go 模块集成,导入也不会加载

当使用带有Go插件的IntelliJIDEA或GoLand并使用Go1.11或更新版本时,您可以通过转到Preferences->Languages&Frameworks->Go->GoModules(vgo)并选中复选框'启用Go模块(vgo)集成”。当你有一个由gomodinit正确初始化的项目,因此有一个go.mod和go.sum文件,当使用gobuild从命令行构建时或通过按绿色播放图标从IntelliJ构建时,它将下载依赖项。但是,远程依赖项的导入语句可能仍然是红色的,即使它们似乎已经下载并出现在go.mod文件中。奇怪的是,go项目实际上将从命令行运行,而不是从Intell

apache - 在 Golang net/http 中设置服务器软件变量

我正在使用ab-c100-n10000http://{yourip}:8000/对我的应用程序进行基准测试,一切都很好,但是像我一样痴迷,我发现在描述服务器时,它返回了ServerSoftware:ServerHostname:localhostServerPort:1337DocumentPath:/DocumentLength:19bytes如何设置服务器软件变量?我无法忍受那里的空地。 最佳答案 设置一个Serverheader。参见RFC-2616section14.38和ResponseWriter.标题.w.Header

Golang 另一个无法识别的导入路径

当我尝试安装golint(或gin,例如)时,出现“无法识别的导入路径错误”。我知道有很多相同的问题,但主要答案是检查环境变量。我的环境变量、我的文件夹和控制台有错误的屏幕截图。我尝试使用.msi安装程序和仅通过复制文件和手动设置envvar来安装go。我得到了相同的结果。 最佳答案 有一个gogetissuecurrentlydiscussedmygotoolswereoutofdate,butgogetcouldnotupdatethembecausetheyswitchedformmercurialtogitatsomepoi

go - 我的主文件找不到我创建的导入到主文件中的另一个文件

我有以下文件结构:-project/-src/-main/-main.go-viewmodels/-home.go-public/我的项目位于:~/go/src/当我试图运行我的主文件时它抛出错误:src/main/main.go:10:2:cannotfindpackage"viewmodels"inanyof:/usr/local/Cellar/go/1.5.3/libexec/src/viewmodels(from$GOROOT)/Users/nicholasrucci/go/src/viewmodels(from$GOPATH)看起来main正在错误的位置寻找packagevi